#include "mytexteidt.h"
#include <QDebug>
#include <QWheelEvent>


MyTextEidt::MyTextEidt(QWidget *parent): QTextEdit(parent)
{

}

void MyTextEidt::wheelEvent(QWheelEvent *e)
{
    if(ctrlKey == 1)
    {
        if(e->angleDelta().y() > 0)
        {
            zoomIn();
        }
        else
        {
            zoomOut();
        }
        //e->accept();//当前组件已处理该事件，不会继续传递给父组件
    }
    else
    {
        QTextEdit::wheelEvent(e);
    }

}

void MyTextEidt::keyPressEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Control)
    {
        ctrlKey = 1;
    }
    QTextEdit::keyPressEvent(e);
}

void MyTextEidt::keyReleaseEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Control)
    {
        ctrlKey = 0;
    }
    QTextEdit::keyPressEvent(e);
}
